<html>
<head>
<title>管理系统</title>
<meta http-equiv=Content-Type content=text/html;charset=utf-8>
<#include "../inc/commonJs.html">
<script language="JavaScript">
	var grid;
	$(function() {
		//分类管理表格  
		grid = $('#imagesgrid').datagrid({
         url:'listImages.do',  
         loadMsg:'数据加载中请稍后……',  
         pagination: true,  
         rownumbers: true, 
         striped: true,  
         singleSelect : true,  
         pageSize: [${syscfg.pageSize!10}],
         pageList: [${syscfg.pageList!10}],
         columns:[[  
             {field:'id',title: 'ID',align: 'center',width: '50'},  
             {field:'title',title: '主题',align: 'center',width: '250'},
             {field:'positionName',title: '位置',align: 'center',width: '150'},
             {field:'url',title: '链接',align: 'center',width: '250'},
             {field:'zt',title: '状态',align: 'center',width: '100',
             	formatter: function(value,rowdata,index){
             		var str = '';
					if(value ==0){
						str += '<a id="btnadd" class="l-btn l-btn-plain" href="javascript:void(0)"><span class="l-btn-left"><span class="l-btn-text icon-no l-btn-icon-left" onclick="shenheImages('+rowdata.id+','+rowdata.zt+')">启用</span></span></a>';
					}else{
						str += '<a id="btnadd" class="l-btn l-btn-plain" href="javascript:void(0)"><span class="l-btn-left"><span class="l-btn-text icon-ok l-btn-icon-left" onclick="shenheImages('+rowdata.id+','+rowdata.zt+')">禁用</span></span></a>';
					}
					return str;
				}
             }]],
             toolbar : [btn_add, btn_edit, btn_del,"-"]
     });
  })
  //新增
	function doAdd() {
		var url = '${request.contextPath}/xadmin/added/imagesWindow.do';
		top.modalwindow(url, grid,{ width:650, height:250,title:'新增图片信息'});
	}
	//工具栏修改
	function doEdit() {
		var selected = grid.datagrid('getSelected');
		if(!selected){
			top.noselectedalert();
			return;
		}
		var url = '${request.contextPath}/xadmin/added/imagesWindow.do?id='+selected.id;
		top.modalwindow(url, grid,{ width:650, height:300,title:'修改图片信息'});
	}
	//工具栏删除
	function doDel(){
		var selected = $('#imagesgrid').datagrid('getSelected');
		if(!selected){
			top.noselectedalert();
			return;
		}
		$.messager.confirm('系统提示', '<br>&nbsp;&nbsp;&nbsp;&nbsp;你确定要删除该信息?', function(r) {
			if (r) {
				$.post("delImages.do", { "id": selected.id},
				   function(data){
				   	grid.datagrid('reload'); 
				   	top.messagershow(data);
				});
			}
		});
	}
	function shenheImages(id,result){
		if(result == 0){
			result = 1;
		}else{
			result = 0;
		}
		$.post("shenheImages.do", 
			{ "id": id,"result":"zt="+result},
		   	function(data){
		   		grid.datagrid('reload'); 
		   		top.messagershow(data);
		});
	}
</script>

</head>
<body>
	<table id="imagesgrid" data-options="fit:true,border:false"></table>
</body>
</html>